package com.wencai.common;

public enum ResponseEnum {
    code_20000("success"),
    code_20001("参数不对"),
    code_89003("请在9点26之后再发起查询"),
    code_89004("请耐心等待数据返回，勿重复请求"),
    code_99999("系统异常，请稍后再试");

    private String message;

    public String getMessage() {
        return message;
    }

    public Integer getCode() {
        return Integer.parseInt(this.name().substring(5));
    }

    public void setMessage(String message) {
        this.message = message;
    }

    ResponseEnum(String message) {
        this.message = message;
    }


    public <T> Result<T> result(T data) {
        Result<T> restResult = new Result<>();

        restResult.setCode(Integer.parseInt(this.name().substring(5)));
        restResult.setMsg(this.message);
        restResult.setData(data);
        return restResult;
    }

    public <T> Result<T> result() {
        Result<T> restResult = new Result<>();
        restResult.setCode(Integer.parseInt(this.name().substring(5)));
        restResult.setMsg(this.message);
        return restResult;
    }


}
